home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / term-source.lha / PhoneLogGenerator.c < prev    next >
C/C++ Source or Header  |  1996-10-20  |  18KB  |  693 lines

  1. #ifndef _HEADERS_H
  2. #include "Headers.h"
  3. #endif    /* _HEADERS_H */
  4.  
  5. /* Copyright © 1996 Kai Hofmann. All rights reserved.
  6. ******* PhoneLog/--history-- ************************************************
  7. *
  8. *   NAME
  9. *    history -- This is the development history of the PhoneLog library
  10. *
  11. *   VERSION
  12. *    $VER: PhoneLog 1.1 (15.03.96)
  13. *
  14. *   HISTORY
  15. *    18.02.1996 -    Concept
  16. *    19.02.1996 -    Implementation
  17. *    05.03.1996 -    Writing Autodocs
  18. *    06.03.1996 -    Improving generator and parser
  19. *    07.03.1996 -    Wrinting Autodocs and improvements for the parser
  20. *    15.03.1996 -    Fixing bugs - now the date/time-format is in
  21. *            correct ISO8601 format
  22. *            closing SGML element now correctly using '/' instead
  23. *            of '\'
  24. *            Better scanner - now supports empty elements
  25. *            Changed SGML DTD - HOSTNAME ist now optional
  26. *            Parser now initialize and insert entry and mark
  27. *            correctly
  28. *            Parser now checks strings for length limitation
  29. *
  30. *****************************************************************************
  31. *
  32. *
  33. */
  34.  
  35. /*
  36. ******* PhoneLog/--release-- ************************************************
  37. *
  38. *   NAME
  39. *    release -- This is the release history of the PhoneLog library
  40. *
  41. *   RELEASE
  42. *    08.03.1996 : V1.0 -    First release on Aminet
  43. *    15.03.1996 : v1.1 -    Second Aminet release
  44. *
  45. *****************************************************************************
  46. *
  47. *
  48. */
  49.  
  50. /*
  51. ******* PhoneLog/--todo-- ***************************************************
  52. *
  53. *   NAME
  54. *    todo -- This is the 'To-Do' list of the PhoneLog library
  55. *
  56. *   TODO
  57. *    Nothing at the moment
  58. *
  59. *****************************************************************************
  60. *
  61. *
  62. */
  63.  
  64. /*
  65. ******* PhoneLog/--announce-- ***********************************************
  66. *
  67. *   TITLE
  68. *    PhoneLog Developer Kit
  69. *
  70. *   VERSION
  71. *    1.1
  72. *
  73. *   RELEASE DATE
  74. *    15.03.1996
  75. *
  76. *   AUTHOR
  77. *    Kai Hofmann (i07m@zfn.uni-bremen.de)
  78. *                (http://www.informatik.uni-bremen.de/~i07m)
  79. *
  80. *   DESCRIPTION
  81. *    Generator and parser for programs that want to write and read log
  82. *    file entries about modem connections in a standard SGML format.
  83. *    Full ANSI-C/C++ source code included.
  84. *
  85. *   NEW FEATURES
  86. *    - Important bug fixes
  87. *    - Improved code
  88. *
  89. *   SPECIAL REQUIREMENTS
  90. *    ANSI-C or/and C++ Compiler.
  91. *
  92. *   AVAILABILITY
  93. *    ftp://wuarchive.wustl.edu/pub/aminet/dev/c/PhoneLogDevKit.lha
  94. *    And all other Aminet sites.
  95. *
  96. *   PRICE
  97. *    For NON-COMMERCIAL USE this is Giftware!
  98. *    (Non-commercial includes Giftware and Shareware!)
  99. *
  100. *    Permission for COMMERCIAL USE is only given by an extra available
  101. *    commercial license that must be validated!
  102. *    Contact me directly for this license, because it will be individually
  103. *    handed out per your needs!
  104. *
  105. *    But in both cases you have to follow the two guidelines below:
  106. *
  107. *    1) You "must" send me a full version of your product at no cost
  108. *       including free updates!
  109. *
  110. *   DISTRIBUTION
  111. *    You can copy and distribute this source code as long as you do not
  112. *    take more than $5 for one disk or $40 for one CD!
  113. *
  114. *****************************************************************************
  115. *
  116. *
  117. */
  118.  
  119. /*
  120. ******* PhoneLog/--compiling-- **********************************************
  121. *
  122. *   NAME
  123. *    compiling -- Specials for compiling the PhoneLog library
  124. *
  125. *   COMPILING
  126. *    - You could compile this code as normal C or as C++
  127. *    - You need only the follwoing files to include:
  128. *      PhoneLog.h, PhoneLogGenerator.h, PhoneLogParserInterface.h
  129. *      If you want to modifiy the scanner and/or parser, you need the
  130. *      following software: Aminet:dev/misc/Toolbox.lha to translate the
  131. *      .rex and .lalr file into C code!
  132. *
  133. *****************************************************************************
  134. *
  135. *
  136. */
  137.  
  138. /*
  139. ******* PhoneLog/--background-- *********************************************
  140. *
  141. *   NAME
  142. *    PhoneLog -- Write and read entries to/from a log file (V33)
  143. *
  144. *   FUNCTION
  145. *    This module has been designed to become a useful and portable library
  146. *    and to help developers to write and read entries to/from a log file
  147. *    in a standard SGML format.
  148. *
  149. *   NOTES
  150. *    It seems that there was no standard for log files that are used
  151. *    to log modem connections etc.
  152. *    So I decided to create a standard based on SGML, because SGML
  153. *    uses the ASCII characterset as base, so it can be used on every
  154. *    platform. On the other hand SGML gives the log file a real structure
  155. *    that is defined by the SGML DTD.
  156. *    By supporting this standard with your software you give the user the
  157. *    possibility to create or evaluate log files with software from
  158. *    different platforms; and you get a standard that is easily extended
  159. *    if a need occurs.
  160. *
  161. *    SGML : Standard Generalized Markup Language
  162. *    DTD  : Document Type Definition
  163. *
  164. *    (English) Books which were consulted in creating this library:
  165. *        The SGML Handbook
  166. *        Charles F. Goldfarb
  167. *        First Edition
  168. *        Oxford University Press, Walton Street, Oxford (USA) 1990
  169. *        ISBN 0-19-853737-9
  170. *
  171. *   COPYRIGHT
  172. *    This software is copyright 1996 by Kai Hofmann.
  173. *    All rights reserved!
  174. *
  175. *    - Permission for COMMERCIAL USE is only given by an extra available
  176. *      commercial license that must be validated!
  177. *      Contact me directly for this license, because it will be
  178. *      individually handed out per your needs!
  179. *
  180. *    - Permission is hereby granted, without written agreement and without
  181. *      license, to USE this software and its documentation for any
  182. *      NON-COMMERCIAL purpose, provided that the above copyright notice
  183. *      and the following paragraph appear in all copies of this software
  184. *      (Non-commercial includes Giftware and Shareware!).
  185. *
  186. *    - THERE IS *NO* PERMISSION GIVEN TO REDISTRIBUTE THIS SOFTWARE IN A
  187. *      MODIFIED FORM!
  188. *
  189. *      You "must" send me a full version of your product at no cost
  190. *      including free updates!
  191. *      Extra money is welcome (For Bank Account see below - but *ONLY*
  192. *      send in DM to this Bank Account!).
  193. *
  194. *   DISCLAIMER
  195. *    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
  196. *    APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  197. *    HOLDER AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  198. *    WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
  199. *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  200. *    A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
  201. *    PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
  202. *    DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  203. *    CORRECTION.
  204. *
  205. *    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  206. *    WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY REDISTRIBUTE
  207. *    THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  208. *    INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
  209. *    ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING
  210. *    BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
  211. *    LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
  212. *    TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
  213. *    PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  214. *
  215. *    THE AUTHOR HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
  216. *    UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  217. *
  218. *   DISTRIBUTION
  219. *    Permission is hereby granted, without written agreement and without
  220. *    license or royalty fees, to copy and distribute this software and its
  221. *    documentation for any purpose, provided that the above copyright
  222. *    notice and the following paragraphs appear in all copies of this
  223. *    software, to:
  224. *    - All who will distribute this software for free!
  225. *    - All free accessible INTERNET servers and PHONE boxes!
  226. *    - All Aminet sites
  227. *    - All SimTel sites
  228. *    - Fred Fish for his great Amiga-Software-Library
  229. *    - The German SAAR AG PD-Library
  230. *    - All others who do NOT take more than $5.- for one disk that
  231. *      includes this software!
  232. *    - ALL others who do NOT take more than $40.- for one CD that includes
  233. *      this software!
  234. *
  235. *   ADDITIONAL INFORMATIONS
  236. *    I have tried to make portable/useful and I hope bugfree software
  237. *    for eternity :)
  238. *    So I hope you will pay a fee for this.
  239. *
  240. *    Kindly send US - dollars to a friend of mine in the USA who will
  241. *    forward it to me in a timely manner.  Please send checks or money
  242. *    orders only.
  243. *    Contact me via email for more details!
  244. *
  245. *   AUTHOR
  246. *    Kai Hofmann
  247. *    Arberger Heerstraße 92
  248. *    28307 Bremen
  249. *    Germany
  250. *
  251. *    Phone: (+49)-(0)421/480780
  252. *           (Remember that my parents don't speak english!)
  253. *    EMail: i07m@zfn.uni-bremen.de
  254. *           i07m@informatik.uni-bremen.de
  255. *    IRC  : PowerStat@#AmigaGer
  256. *    WWW  : http://www.informatik.uni-bremen.de/~i07m
  257. *
  258. *    Bank account : 1203 7503
  259. *    Account owner: Kai Hofmann
  260. *    Bank code    : 290 501 01
  261. *    Bank name    : Sparkasse in Bremen/Germany
  262. *
  263. *    THANKS
  264. *    Thank you's are going to the following people:
  265. *    Rita Reichl        - For correcting my English.
  266. *    James Cooper and the
  267. *    other Amiga people at
  268. *    SAS Intitute        - For spending their unpaid free time with
  269. *                  continuation of the Amiga SAS C/C++
  270. *                  support :)
  271. *
  272. *****************************************************************************
  273. *
  274. *
  275. */
  276.  
  277.  
  278. #ifndef _PHONELOGGENERATOR_H
  279. #include "PhoneLogGenerator.h"
  280. #endif    /* _PHONELOGGENERATOR_H */
  281.  
  282. #ifndef _PHONELOG_H
  283. #include "PhoneLog.h"
  284. #endif    /* _PHONELOG_H */
  285.  
  286. #include <stdarg.h>
  287.  
  288. #ifndef EXEC_MEMORY_H
  289. #include <exec/memory.h>
  290. #endif
  291.  
  292. #ifndef DOS_DOS_H
  293. #include <dos/dos.h>
  294. #endif
  295.  
  296. #ifndef CLIB_DOS_PROTOS_H
  297. #include <clib/dos_protos.h>
  298. #endif
  299.  
  300. #ifndef CLIB_EXEC_PROTOS_H
  301. #include <clib/exec_protos.h>
  302. #endif
  303.  
  304. extern struct ExecBase        *SysBase;
  305. extern struct DosLibrary    *DOSBase;
  306.  
  307. STATIC void
  308. LogPrintf(PhoneLogHandle *handle,char *format,...)
  309. {
  310.     if(handle->error == 0)
  311.     {
  312.         va_list args;
  313.  
  314.         va_start(args,format);
  315.  
  316.         if(VFPrintf(handle->file,format,(APTR)args) == -1)
  317.             handle->error = IoErr();
  318.  
  319.         va_end(args);
  320.     }
  321. }
  322.  
  323. /*
  324. ******* PhoneLogGenerator/OpenPhoneLog **************************************
  325. *
  326. *   NAME
  327. *    OpenPhoneLog -- Opens a log file for write operations (V33)
  328. *
  329. *   SYNOPSIS
  330. *    file = OpenPhoneLog(name);
  331. *
  332. *    BPTR OpenPhoneLog(char *name);
  333. *
  334. *   FUNCTION
  335. *    Opens a log file for appending new entries. If the log file doesn't
  336. *    exist, a new one will be created.
  337. *
  338. *   INPUTS
  339. *    name - The name of the log file.
  340. *
  341. *   RESULT
  342. *    file - stdio.h file descriptor for a level 2 file or NULL if an error
  343. *        occurs.
  344. *
  345. *   EXAMPLE
  346. *    ...
  347. *    BPTR file;
  348. *
  349. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  350. *    ...
  351. *    ClosePhoneLog(file);
  352. *    ...
  353. *
  354. *   NOTES
  355. *    None
  356. *
  357. *   BUGS
  358. *    No known bugs.
  359. *
  360. *   SEE ALSO
  361. *    ClosePhoneLog(),WritePhoneLogStartEntry(),WritePhoneLogEndEntry(),
  362. *    WritePhoneLogEntry(),WritePhoneLogMark()
  363. *
  364. *****************************************************************************
  365. *
  366. *
  367. */
  368.  
  369. PhoneLogHandle *
  370. OpenPhoneLog(char *name)
  371. {
  372.     PhoneLogHandle *handle;
  373.     BPTR fileLock;
  374.     BPTR file;
  375.  
  376.     if(handle = AllocVec(sizeof(PhoneLogHandle),MEMF_ANY|MEMF_CLEAR))
  377.     {
  378.         if(fileLock = Lock(name,EXCLUSIVE_LOCK))
  379.         {
  380.             if(!(file = OpenFromLock(fileLock)))
  381.             {
  382.                 UnLock(fileLock);
  383.  
  384.                 file = Open(name,MODE_READWRITE);
  385.             }
  386.  
  387.             if(file)
  388.             {
  389.                 if(Seek(file,0,OFFSET_END) != -1)
  390.                 {
  391.                     handle->file = file;
  392.  
  393.                     return(handle);
  394.                 }
  395.  
  396.                 Close(file);
  397.             }
  398.         }
  399.         else
  400.         {
  401.             if(file = Open(name,MODE_NEWFILE))
  402.             {
  403.                 handle->file = file;
  404.  
  405.                 LogPrintf(handle,"<PHONELOG");
  406.                 LogPrintf(handle," version=1 revision=1");
  407.                 LogPrintf(handle,">\n");
  408.  
  409.                 if(handle->error != 0)
  410.                 {
  411.                     Close(file);
  412.                     DeleteFile(name);
  413.  
  414.                     SetIoErr(handle->error);
  415.  
  416.                     FreeVec(handle);
  417.  
  418.                     return(NULL);
  419.                 }
  420.  
  421.                 return(handle);
  422.             }
  423.         }
  424.  
  425.         FreeVec(handle);
  426.     }
  427.  
  428.     return(NULL);
  429. }
  430.  
  431.  
  432. /*
  433. ******* PhoneLogGenerator/ClosePhoneLog *************************************
  434. *
  435. *   NAME
  436. *    ClosePhoneLog -- Close a log file (V33)
  437. *
  438. *   SYNOPSIS
  439. *    ClosePhoneLog(file);
  440. *
  441. *    void ClosePhoneLog(BPTR file);
  442. *
  443. *   FUNCTION
  444. *    Close a log file opened by OpenPhoneLog().
  445. *
  446. *   INPUTS
  447. *    file - The stdio.h file descriptor for a level 2 file that you got
  448. *        from OpenPhoneLog().
  449. *
  450. *   RESULT
  451. *    None
  452. *
  453. *   EXAMPLE
  454. *    ...
  455. *    BPTR file;
  456. *
  457. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  458. *    ...
  459. *    ClosePhoneLog(file);
  460. *    ...
  461. *
  462. *   NOTES
  463. *    None
  464. *
  465. *   BUGS
  466. *    No known bugs.
  467. *
  468. *   SEE ALSO
  469. *    OpenPhoneLog(),WritePhoneLogStartEntry(),WritePhoneLogEndEntry(),
  470. *    WritePhoneLogEntry(),WritePhoneLogMark()
  471. *
  472. *****************************************************************************
  473. *
  474. *
  475. */
  476.  
  477. void
  478. ClosePhoneLog(PhoneLogHandle *handle)
  479. {
  480.     if(handle)
  481.     {
  482.         Close(handle->file);
  483.         FreeVec(handle);
  484.     }
  485. }
  486.  
  487.  
  488. /*
  489. ******* PhoneLogGenerator/WritePhoneLogStartEntry ***************************
  490. *
  491. *   NAME
  492. *    WritePhoneLogStartEntry -- Write the start to a log file (V33)
  493. *
  494. *   SYNOPSIS
  495. *    WritePhoneLogStartEntry(file, item);
  496. *
  497. *    void WritePhoneLogStartEntry(BPTR file,
  498. *        struct PhoneLogEntry *item);
  499. *
  500. *   FUNCTION
  501. *    Write the start data for a connection to a log file opened by
  502. *    OpenPhoneLog().
  503. *
  504. *   INPUTS
  505. *    file - The stdio.h file descriptor for a level 2 file that you got
  506. *        from OpenPhoneLog().
  507. *    item - PhoneLogEntry structure. You must fill in following fields:
  508. *        Number, StartDay, StartMonth, StartYear, StartHour,
  509. *        StartMin, StartSec.
  510. *        The fields Name and Reason are optional and will only be written
  511. *        if the string length is greater than 0.
  512. *
  513. *   RESULT
  514. *    None
  515. *
  516. *   EXAMPLE
  517. *    ...
  518. *    BPTR file;
  519. *    struct PhoneLogEntry item;
  520. *
  521. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  522. *    ...
  523. *    strcpy(item.Number,"1234567890");
  524. *    strcpy(item.Name,"University");
  525. *    item.StartDay = 5;
  526. *    item.StartMonth = 3;
  527. *    item.StartYear = 1996; \* NOT 96! *\
  528. *    item.StartHour = 12;
  529. *    item.StartMin = 3;
  530. *    item.StartSec = 0;
  531. *    WritePhoneLogStartEntry(file,item);
  532. *    ...
  533. *    ClosePhoneLog(file);
  534. *    ...
  535. *
  536. *   NOTES
  537. *    Set Reason[0] = '\0' if you not want that this will be written to
  538. *    the log file.
  539. *
  540. *   BUGS
  541. *    No known bugs.
  542. *
  543. *   SEE ALSO
  544. *    OpenPhoneLog(),ClosePhoneLog(),WritePhoneLogEndEntry(),
  545. *    WritePhoneLogEntry(),WritePhoneLogMark()
  546. *
  547. *****************************************************************************
  548. *
  549. *
  550. */
  551.  
  552. void
  553. WritePhoneLogStartEntry(PhoneLogHandle *handle, struct PhoneLogEntry *item)
  554. {
  555.     if(handle != NULL && item != NULL)
  556.     {
  557.         LogPrintf(handle,"\n<ENTRY>\n");
  558.         LogPrintf(handle,"  <HOST>\n");
  559.         LogPrintf(handle,"    <NUMBER>");
  560.         LogPrintf(handle,"%s",item->Number);
  561.         LogPrintf(handle,"</NUMBER>\n");
  562.  
  563.         if (item->Name[0] != '\0')
  564.         {
  565.             LogPrintf(handle,"    <HOSTNAME>");
  566.             LogPrintf(handle,"%s",item->Name);
  567.             LogPrintf(handle,"</HOSTNAME>\n");
  568.         }
  569.  
  570.         if (item->Reason[0] != '\0')
  571.         {
  572.             LogPrintf(handle,"    <REASON>");
  573.             LogPrintf(handle,"%s",item->Reason);
  574.             LogPrintf(handle,"</REASON>\n");
  575.         }
  576.  
  577.         LogPrintf(handle,"  </HOST>\n");
  578.         LogPrintf(handle,"  <START>\n");
  579.         LogPrintf(handle,"    <DATE>");
  580.         LogPrintf(handle,"%04ld-%02ld-%02ld",item->StartYear,item->StartMonth,item->StartDay);
  581.         LogPrintf(handle,"</DATE>\n");
  582.         LogPrintf(handle,"    <TIME>");
  583.         LogPrintf(handle,"%02ld:%02ld:%02ld",item->StartHour,item->StartMin,item->StartSec);
  584.         LogPrintf(handle,"</TIME>\n");
  585.         LogPrintf(handle,"  </START>\n");
  586.     }
  587. }
  588.  
  589. /*
  590. ******* PhoneLogGenerator/WritePhoneLogEndEntry *****************************
  591. *
  592. *   NAME
  593. *    WritePhoneLogEndEntry -- Write the end to a log file (V33)
  594. *
  595. *   SYNOPSIS
  596. *    WritePhoneLogEndEntry(file, item);
  597. *
  598. *    void WritePhoneLogEndEntry(BPTR file,
  599. *        struct PhoneLogEntry *item);
  600. *
  601. *   FUNCTION
  602. *    Write the end data for a connection to a log file opened by
  603. *    OpenPhoneLog() after you have used WritePhoneLogStartEntry()!
  604. *
  605. *   INPUTS
  606. *    file - The stdio.h file descriptor for a level 2 file that you got
  607. *        from OpenPhoneLog().
  608. *    item - PhoneLogEntry structure. You must fill in following fields:
  609. *        EndDay, EndMonth, EndYear, EndHour, EndMin, EndSec
  610. *        If you want you can optionally fill in the fields:
  611. *        Hours, Mins, Secs
  612. *
  613. *   RESULT
  614. *    None
  615. *
  616. *   EXAMPLE
  617. *    ...
  618. *    BPTR file;
  619. *    struct PhoneLogEntry item;
  620. *
  621. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  622. *    ...
  623. *    item.EndDay = 5;
  624. *    item.EndMonth = 3;
  625. *    item.EndYear = 1996; \* NOT 96! *\
  626. *    item.EndHour = 12;
  627. *    item.EndMin = 17;
  628. *    item.EndSec = 0;
  629. *    WritePhoneLogEndEntry(file,item);
  630. *    ...
  631. *    ClosePhoneLog(file);
  632. *    ...
  633. *
  634. *   NOTES
  635. *    If you want to write the optional fields Hours, Mins, Secs to the log
  636. *    file, please remove the second comment from the source code!
  637. *    If you want that EndDay, EndMonth and EndYear will only be written
  638. *    to the log file if they are different to the start date, then please
  639. *    remove the first comment from the source code, but keep in mind
  640. *    that you now must fill the structure with StartDay, StartMonth and
  641. *    StartYear too!
  642. *
  643. *   BUGS
  644. *    No known bugs.
  645. *
  646. *   SEE ALSO
  647. *    OpenPhoneLog(),ClosePhoneLog(),WritePhoneLogStartEntry(),
  648. *    WritePhoneLogEntry(),WritePhoneLogMark()
  649. *
  650. *****************************************************************************
  651. *
  652. *
  653. */
  654.  
  655. void
  656. WritePhoneLogEndEntry(PhoneLogHandle *handle, struct PhoneLogEntry *item)
  657. {
  658.     if(handle != NULL && item != NULL)
  659.     {
  660.         LogPrintf(handle,"  <END>\n");
  661.         /*if (StartDate != EndDate)*/
  662.         {
  663.             LogPrintf(handle,"    <DATE>");
  664.             LogPrintf(handle,"%04ld-%02ld-%02ld",item->EndYear,item->EndMonth,item->EndDay);
  665.             LogPrintf(handle,"</DATE>\n");
  666.         }
  667.         LogPrintf(handle,"    <TIME>");
  668.         LogPrintf(handle,"%02ld:%02ld:%02ld",item->EndHour,item->EndMin,item->EndSec);
  669.         LogPrintf(handle,"</TIME>\n");
  670.         LogPrintf(handle,"  </END>\n");
  671.         /*
  672.         if ((item->Hours > 0) || (item->Mins > 0) || (item->Secs > 0))
  673.         {
  674.             LogPrintf(handle,"  <PERIOD>");
  675.             if (item->Hours > 0)
  676.             {
  677.                 LogPrintf(handle,"%ldH",item->Hours);
  678.             }
  679.             if (item->Mins > 0)
  680.             {
  681.                 LogPrintf(handle,"%02ldM",item->Mins);
  682.             }
  683.             if (item->Secs > 0)
  684.             {
  685.                 LogPrintf(handle,"%02ldS",item->Secs);
  686.             }
  687.             LogPrintf(handle,"</PERIOD>\n");
  688.         }
  689.         */
  690.         LogPrintf(handle,"</ENTRY>\n");
  691.     }
  692. }
  693.